package com.mmall.common;

import com.baomidou.mybatisplus.enums.IEnum;
import com.google.common.collect.Sets;

import java.io.Serializable;
import java.util.Set;

/**
 * Created by hanchao on 2018/1/9.
 */
public class Const implements IEnum {
    public static final String CURRENT_USER ="currentuser";
    public static final String EMAIL = "email";
    public static final String USERNAME = "username";

    @Override
    public Serializable getValue() {
        return null;
    }

    public interface Role{
        int ROLE_CUSTOMER =0; //普通用户
        int ROLE_ADMIN = 1;      //管理员
    }
    public interface Cart{
        int CHECKED =1;  //选中状态
        int UN_CHECKED =0; //未选中状态

        String BUY_LIMIT_FAIL = "BUY_LIMIT_FAIL";
        String BUY_LIMIT_SUCCESS = "BUY_LIMIT_SUCCESS";
    }
    public interface Alipay{
        /**   APP支付 */
        String QUICK_MSECURITY_PAY ="QUICK_MSECURITY_PAY";
        /**   PC支付 */
        String FAST_INSTANT_TRADE_PAY ="FAST_INSTANT_TRADE_PAY";
        /**   移动H5支付 */
        String QUICK_WAP_PAY = "QUICK_WAP_PAY";

    }
    public interface ProductListOrderBy{
        Set<String> PRICE_ASC_DESC = Sets.newHashSet("price_asc","price_desc");
    }
    public enum ProductStatusEnum{
        ON_SALE(1,"在线");
        private String value;
        private int code;
        ProductStatusEnum(int code,String value){
            this.code = code;
            this.value = value;
        }
        public String getValue(){
            return this.value;
        }
        public int getCode(){
            return this.code;
        }
    }

    public enum OrderStatusEnums{
        CANCELE(0,"已取消"),
        NO_PAY(10,"未支付"),
        PAID(20,"已支付"),
        SHIPPED(40,"已发货"),
        ORDER_SUCCESS(50,"订单完成"),
        ORDER_CLOSE(60,"订单关闭");
        private String value;
        private int code;

        OrderStatusEnums(int code,String value){
            this.code = code;
            this.value = value;
        }


        public int getCode(){
            return this.code;
        }
        public String getValue(){
            return this.value;
        }

        public static OrderStatusEnums codeOf(int code){
            for(OrderStatusEnums OrderStatusEnums: values()){
                if(OrderStatusEnums.getCode() == code){
                    return OrderStatusEnums;
                }
            }
            throw new RuntimeException("没有找到对应的枚举");
        }
    }
    public interface AlipayCallback{
        String TRADE_SUCCESS = "TRADE_SUCCESS";
        String TRADE_WAIT_BUYER_PAY = "WAIT_BUYER_PAY";

        String RESPONSE_SUCCESS = "success";
        String RESPONSE_FAILED ="failed";
    }

    public enum  PayPlatFormEnum{
        ALIPAY(1,"支付宝");

        private String value;
        private int code;
        PayPlatFormEnum(int code,String value){
            this.code = code;
            this.value = value;
        }
        public String getValue(){
            return this.value;
        }
        public int getCode(){
            return this.code;
        }
    }
    public enum PaymentTypeEnum{
       ONLINE_PAY(1,"在线支付");
        PaymentTypeEnum(int code,String value){
            this.code = code;
            this.value = value;
        }
        private String value;
        private int code;
        public String getValue(){
            return this.value;
        };
        public int getCode(){
            return this.code;
        }

        public static PaymentTypeEnum codeOf(int code){
            for(PaymentTypeEnum paymentTypeEnum: values()){
                if(paymentTypeEnum.getCode() == code){
                    return paymentTypeEnum;
                }
            }
            throw new RuntimeException("没有找到对应的枚举");
        }
    }

}
